package com.example.app.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.example.app.R;
import com.example.app.data.MMissionBean;

import java.util.List;

public class MMCAdapter extends BaseAdapter {

    private MMissionBean bean;
    private Context context;

    public MMCAdapter(MMissionBean data,Context context)
    {
        this.bean=data;
        this.context=context;
    }

    @Override
    public int getCount() {
        return 9;
    }

    @Override
    public Object getItem(int i) {
        return null;
    }

    @Override
    public long getItemId(int i) {
        return i;
    }

    @Override
    public View getView(int i, View view, ViewGroup viewGroup) {
        MMCAdapter.ViewHolder viewHolder;
        if(view==null)
        {
            viewHolder=new MMCAdapter.ViewHolder();
            view= LayoutInflater.from(context).inflate(R.layout.user_count,viewGroup,false);
            viewHolder.name=view.findViewById(R.id.uc_user);
            viewHolder.value= view.findViewById(R.id.uc_password);
            view.setTag(viewHolder);
        }else {
            viewHolder = (MMCAdapter.ViewHolder) view.getTag();
        }
        switch(i)
        {
            case 0:
                viewHolder.name.setText("任务编号");
                viewHolder.value.setText(bean.getMissionNumber()+"");
                break;
            case 1:
                viewHolder.name.setText("任务名称");
                viewHolder.value.setText(bean.getMissionName());
                break;
            case 2:
                viewHolder.name.setText("业务场景");
                viewHolder.value.setText(bean.getMissionPlace());
                break;
            case 3:
                viewHolder.name.setText("安全等级");
                viewHolder.value.setText(bean.getSecureLevel());
                break;
            case 4:
                viewHolder.name.setText("委托单位");
                viewHolder.value.setText(null);
                break;
            case 5:
                viewHolder.name.setText("接入类型");
                viewHolder.value.setText(null);
                break;
            case 6:
                viewHolder.name.setText("系统架构");
                viewHolder.value.setText(null);
                break;
            case 7:
                viewHolder.name.setText("数据库版本");
                viewHolder.value.setText(null);
                break;
            case 8:
                viewHolder.name.setText("软件版本号");
                viewHolder.value.setText(null);
                break;
        }

        return view;
    }

    private final class ViewHolder{
        TextView name;
        TextView value;
    }
}
